package demo3;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

public class User {
    String name;
    Address addr;
    List<String>hobbies;
    //用于把前端字符串传入后台时，自动转换成Date
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    //用于在转换成json字符串时，修改其key,使其跟前端保持一致
    @JsonProperty("birthday")
    //用于把后端对象转换成json字符串时，因为其默认转换成毫秒数，该注解可把其转换成字符串
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    Date birth;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Address getAddr() {
        return addr;
    }

    public void setAddr(Address addr) {
        this.addr = addr;
    }

    public List<String> getHobbies() {
        return hobbies;
    }

    public void setHobbies(List<String> hobbies) {
        this.hobbies = hobbies;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", addr=" + addr +
                ", hobbies=" + hobbies +
                ", birth=" + birth +
                '}';
    }
}
